import React, { Component } from 'react';
import { View, Text } from 'react-native';
import { observer } from 'mobx-react';
import { Scene, Actions } from 'react-native-router-flux';
import navBarStyle from '../../../components/navBarStyle';
import user from '../../../common/models/user';
import activities from '../models/activities';
import NotAuthorized from './components/notAuthorized';
import List from './components/list';

@observer
class ActivityList extends Component {
  render() {
    return (
      <View style={{flex: 1}}>
        {this.props.user.userInfo.institutionId ? null : (
          <NotAuthorized user={this.props.user} />
        )}
        <List
          user={user}
          listData={this.props.activities.list}
          pending={this.props.activities.pending}
          activities={this.props.activities}
        />
      </View>
    );
  }
}

module.exports = (
  <Scene
    key="activityList"
    initial
    component={ActivityList}
    title="活动"
    path="/activities"
    activities={activities}
    user={user}
    {...navBarStyle}
    onEnter={activities.init.bind(activities)}
  />
);
/* 
关于上下文的问题:
在将某个类实例的方法作为回调时, 有多种写法:
1, onEvent={() => classInstance.mathod()}
2, onEvent={classInstance.mathod.bind(classInstance)}
3, onEvent={classInstance.mathod.apply(classInstance)}
4, onEvent={classInstance.mathod.call(classInstance)}
5, onEvent={classInstance.mathod}
#1,#2,#3,#4的上下文都可以绑定实例, #5的上下文是global,如果方法不是纯函数很可能会出错
建议适应第一种
*/
